package com.taihua.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//import javax.annotation.PostConstruct;
//import javax.annotation.PreDestroy;

//类前加 注解@Component
@Component
@Scope("singleton")

public class Person {

    @Value("1")
    private Integer id;

    @Value("苏小落")
    private String name;

    @Value("18")
    private Integer age;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @PostConstruct
    public void init(){
        System.out.println("对象创建初始化后执行");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("对象实现销毁前执行");
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
